/**
*      author: Y_Yao
*      created: 2025-01-24 12:27:12
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 3e5 + 7;
int q[N];
int n,m,k;

void solve()
{
    cin >> n >> m >> k;
    int sub1 = 0,sub2 = 0;
    string ans;
    string ans2;
    vector<int> a(m,0);
    for(int i = 0;i < m;i++)
    {
        cin >> a[i];
        ans += '1';
        ans2 += '0';
    }

    int cant = 1;
    for(int i = 1;i <= k;i++)
    {
        cin >> q[i];
        if(q[i] == cant) cant++;
    }

    if(k == n)
    {
        cout << ans << endl;
        return;
    }
    else if(k < n - 1)
    {
        cout << ans2 << endl;
        return;
    }
    else if(k == n - 1)
    {
        string ret;
        for(auto& v : a)
        {
            if(v == cant) ret += '1';
            else ret += '0';
        }
        cout << ret << endl;;
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}